.TH E1432_INTR 5 E1432
.SH NAME
e1432_intr \- Description of E1432 interrupt behavior
.IX e1432_intr(5) 5
.SH DESCRIPTION

.B E1432 Interrupt Setup

The E1432 VXI module can be programmed to interrupt a host computer
using the VME interrupt lines.  VME provides seven such lines, and the
E1432 module can be told to use any one of them (see
\fIe1432_set_interrupt_priority\fR).

The E1432 can interrupt the host computer in response to different
events.  The user can specify a \fImask\fR of events on which to
interrupt.  This mask is created by ORing together the various
conditions that the user wants.  The following table, copied from the
\fIe1432_set_interrupt_mask\fR manual page, shows the conditions that
can cause an interrupt:

.ne 13
.TS
box center;
c s
c | c
l | l.
Interrupt Mask Bit Definitions
_
Define (in e1432.h)	Description
=
E1432_IRQ_BLOCK_READY	Scan of data ready in FIFO
E1432_IRQ_MEAS_ERROR	FIFO overflow
E1432_IRQ_MEAS_STATE_CHANGE	Measurment state machine changed state
E1432_IRQ_MEAS_WARNING	Measurement warning
E1432_IRQ_OVERLOAD_CHANGE	Overload/underrange status changed
E1432_IRQ_SRC_STATUS	Source channel interrupt
E1432_IRQ_TACHS_AVAIL	Raw tach times ready for transfer to other modules
E1432_IRQ_TRIGGER	Trigger ready for transfer to other modules
.TE

The \fBE1432_IRQ_SRC_STATUS\fR interrupt is used for source channel
overload, overread, and shutdown.  When the source is in arb data
mode, this interrupt is also used for the "ready for arb data"
interrupt.

The \fBE1432_IRQ_MEAS_ERROR\fR currently is used only for a FIFO
overflow.  This will interrupt as soon as the FIFO overflows, but note
that the FIFO still has useful data in it which can still be read by
the \fIe1432_read_xxx_data\fR functions.  \fIe1432_block_available\fR
will not indicate that a FIFO overflow has occurred until all of the
remaining data is read out of the FIFO.

.B E1432 Interrupt Handling

To make the E1432 module do the interrupt, both a \fImask\fR and a
\fIVME Interrupt line\fR must be specified, by calling
\fIe1432_set_interrupt_mask\fR and \fIe1432_set_interrupt_priority\fR
respectively.  Once the mask and line have been set, and an interrupt
occurs, the cause of the interrupt can be obtained by reading the
\fBE1432_IRQ_STATUS2_REG\fR register (using \fIe1432_read_register\fR).
The bit positions of the interrupt mask and status registers match so
the defines can be used to set and check IRQ bits.

Once it has done this interrupt, the module will not do any more VME
interrupts until re-enabled with \fIe1432_reenable_interrupt\fR.
Normally, the last thing a host computer's interrupt handler should do
is call \fIe1432_reenable_interrupt\fR.

Events that would have caused an interrupt, but which are blocked
because \fIe1432_reenable_interrupt\fR has not yet been called, will
be saved.  After \fIe1432_reenable_interrupt\fR is called, these saved
events will cause an interrupt, so that there is no way for the host
to "miss" an interrupt.  However, the module will only do one VME
interrupt for all of the saved events, so that the host computer will
not get flooded with too many interrupts.

For things like "E1432_IRQ_BLOCK_READY", which are not events but are
actually states, the module will do an interrupt after
\fIe1432_reenable_interrupt\fR only if the state is still present.
This allows the host computer's interrupt handler to potentially read
multiple scans from an E1432 module, and not get flooded with block
ready interrupts after the fact.

.B Host Interrupt Setup

The E1432 Host Interface library normally uses the SICL I/O library to
communicate with the E1432 hardware.  To receive VME interrupts, a
variety of SICL setup calls must be made.  The "examples" directory of
the E1432 distribution contains an example of setting up SICL to
receive interrupts from an E1432 module.

This is a summary of how to set up SICL to receive an E1432 interrupt:

.IP "1." 5
Query SICL for which VME interrupt lines are available, using
\fIivxibusstatus\fR and \fIivxirminfo\fR.
.IP "2." 5
Tell the E1432 module to use the VME interrupt line found in step
one, using \fIe1432_set_interrupt_priority\fR.
.IP "3." 5
Set up an interrupt handler routine, using \fIionintr\fR and
\fIisetintr\fR.  The interrupt handler routine will get called when
the interrupt occurs.
.IP "4." 5
Set up interrupt mask in the E1432 module, using
\fIe1432_set_interrupt_mask\fR.
.PP

.B Host Interrupt Handling

When the E1432 asserts the VME interrupt line, SICL will cause the
specified interrupt handler to get called.  Typically the interrupt
handler routine will read data from the module, and then re-enable
E1432 interrupts with \fIe1432_reenable_interrupt\fR.  The call to
\fIe1432_reenable_interrupt\fR must be done unless the host is not
interested in any more interrupts.

Inside the interrupt handler, almost any E1432 Host Interface library
function can be called.  This works because the Host Interface library
disables interrupts around critical sections of code, ensuring that
communication with the E1432 module stays consistent.  Things that are
\fInot\fR valid in the handler are:

.IP "1." 5
Calling \fIe1432_delete_channel_group\fR to delete a group that is
simultaneously being used by non-interrupt-handler code.
.IP "2." 5
Calling one of the read data functions (\fIe1432_read_raw_data\fR,
\fIe1432_read_float32_data\fR, or \fIe1432_read_float64_data\fR), if
the non-interrupt-handler code is also calling one of these functions.
.IP "3." 5
Calling \fIe1432_assign_channel_numbers\fR to reset the list of
channels that are available to the E1432 library.
.PP

As is always the case with interrupt handlers, it is easy to introduce
bugs into your program, and generally hard to track down these bugs.
Be careful when writing this function.

.SH "SEE ALSO"
.na
e1432_set_interrupt_priority, e1432_set_interrupt_mask,
e1432_reenable_interrupt
.ad
